/** 
 * Project Name:tinysql 
 * File Name:MssqlSqlTypeConverter.java 
 * Package Name:com.wdy.golden.tinysql.extend 
 * Date:2021年4月8日上午9:46:36 
 * 
*/  
package com.wdy.golden.tinysql.extend;

import java.math.BigDecimal;
import java.sql.Date;
import java.sql.Timestamp;
import java.sql.Types;

/** 
 * ClassName:MssqlSqlTypeConverter <br/> 
 * Function: TODO ADD FUNCTION. <br/> 
 * Reason:   TODO ADD REASON. <br/> 
 * Date:     2021年4月8日 上午9:46:36 <br/> 
 * @author   DongYe_Wu 
 * @version
 * @see       
 */
public class MssqlSqlTypeConverter implements SqlTypeConverter {
	@Override
	public int getJdbcTypeByObject(Object var1) {
		return getJdbcTypeByObject(var1, false);
	}
	
	@Override
	public int getJdbcTypeByObject(Object var1, boolean fixedString) {
		if (var1 == null) {
			return 0;
		}else {
			if (var1 instanceof String) {
				return Types.VARCHAR;
			}
			if (var1 instanceof Long) {
				return Types.BIGINT;
			}
			if (var1 instanceof Boolean) {
				return Types.BIT;
			}
			if (var1 instanceof Integer) {
				return Types.INTEGER;
			}
			if (var1 instanceof Timestamp) {
				return Types.TIMESTAMP;
			}
			if (var1 instanceof Date) {
				return Types.DATE;
			}
			if (var1 instanceof BigDecimal) {
				return Types.DECIMAL;
			}
			if (var1 instanceof Double) {
				return Types.DOUBLE;
			}
			if (var1 instanceof Float) {
				return Types.REAL;
			}
			if (var1 instanceof Short) {
				return Types.SMALLINT;
			}
			if (var1 instanceof byte[]) {
				return Types.VARBINARY;
			}
		}
		
		return Types.OTHER;
	}
}
